import { _decorator, Component, Node } from 'cc';
import { StateDefine } from '../../Config';
import { SkeletonGroundState } from './SkeletonGroundState';
const { ccclass, property } = _decorator;

@ccclass('SkeletonMoveState')
export class SkeletonMoveState extends SkeletonGroundState {
    onEnter() {
        super.onEnter();
    }
    update(deltaTime: number) {
        this.enemy.setVelocity(this.enemy.MoveSpeed*this.enemy.facingDir,this.rb.linearVelocity.y);
        if(this.enemy.IsWallDetected()||!this.enemy.IsGroundDetected()){
            this.enemy.Flip();
            this.enemy.stateMgr.transit(StateDefine.SkeletonIdle);
        }
        super.update(deltaTime);
    }
    onExit() {
        super.onExit();
    }
}


